<template>
	<view class="my-order">
		<view class="order-tabs">
			<view :class="['tab-item', isActive == item.type ? 'active' : '']" v-for="(item,i) in tabsList" :key="i"
				@tap="tabActive(item)">
				{{ item.name }}
			</view>
		</view>
		<view class="order-list">
			<view class="order-item" v-for="(order, i) in orderList" :key="i">
				<view class="order-item-t">
					<view class="order-id">
						<view class="left-id">订单号：{{ order.order_id }}</view>
						<view class="right-status">{{ order.title }}</view>
					</view>
					<view class="ls"@tap="$Router.push({path: '/pages/order/detail', query: {
						from: 'default'
					}})">
						<view class="item-ls" v-for="(orderls, i) in order.order_data" :key="i">
							<image class="ls-img" :src="orderls.img" mode="aspectFill"></image>
							<view class="ls-msg">
								<view class="left-msg">
									<view class="ls-title">{{ orderls.name }}</view>
									<view class="ls-size">{{ orderls.size }}</view>
									<view class="ls-price">￥{{ orderls.price }}</view>
								</view>
								<view class="right-num">X{{ orderls.num }}</view>
							</view>
						</view>
					</view>
					<view class="goods-total">
						<view class="total-text">
							共2件商品，合计：
						</view>
						<view class="total-price">
							￥<text class="text-">{{ order.total_price }}</text>
						</view>
					</view>
					<view class="order-btn-s">
						<view class="btn-s" v-if="order.order_status == 'obligation'">立即付款</view>
						<view class="btn-s" v-if="order.order_status == 'wait'">确认收货</view>
						<view class="btn-s" v-if="order.order_status == 'all'">再次购买</view>
						<view class="btn-s_" v-if="order.order_status == 'obligation'">取消订单</view>
						<view class="btn-s_" @tap="$Router.push('/pages/order/aftersales')" v-if="order.order_status == 'wait' || order.order_status == 'all'">申请售后</view>
						<view class="btn-s__" v-if="order.order_status == 'sale'" @tap="$Router.push({path: '/pages/order/detail', query: { from: 'result' }})">查看结果</view>

					</view>
				</view>
				<view class="item-line-t"></view>
			</view>
		</view>
	</view>
</template>

<script>
	import sortData from '../../common/sortData.js'
	export default {
		data() {
			return {
				isActive: 'all',
				tabsList: sortData.tabsList,
				orderList: sortData.orderData
			};
		},
		methods: {
			tabActive(item) {
				this.isActive = item.type
			}
		}
	}
</script>

<style lang="scss">
	.my-order {}

	.order-tabs {
		width: 750rpx;
		height: 84rpx;
		border-radius: 5rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 39rpx 0 37rpx;
		box-sizing: border-box;

		.tab-item {
			font-size: 28rpx;
			letter-spacing: 3rpx;
			color: #787878;

			&.active {
				color: #333333;
				position: relative;

				&:before {
					content: '';
					display: block;
					width: 100%;
					height: 4rpx;
					background-color: #c60122;
					border-radius: 2rpx;
					position: absolute;
					left: 50%;
					bottom: -25rpx;
					transform: translateX(-50%);
				}
			}
		}
	}

	.order-list {
		background-color: #fff;

		.order-item {

			.order-item-t {
				padding: 44rpx 0 22rpx 0;
			}

		}

		.order-id {
			padding: 0 20rpx 20rpx 33rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1px solid #e5e5e5;

			.left-id {
				font-size: 24rpx;
				letter-spacing: 2rpx;
				color: #545454;
			}

			.right-status {
				font-size: 26rpx;
				letter-spacing: 3rpx;
				color: #c60122;
			}
		}

		.ls {
			padding: 0 20rpx 0 17rpx;

			.item-ls {
				padding: 28rpx 37rpx 28rpx 16rpx;
				display: flex;
				border-bottom: 1px solid #e5e5e5;

				.ls-img {
					width: 146rpx;
					height: 146rpx;
					border-radius: 5rpx;
					margin-right: 34rpx;
				}

				.ls-msg {
					display: flex;
					justify-content: space-between;
					width: 480rpx;

					.ls-title {
						font-size: 28rpx;
						letter-spacing: 3rpx;
						color: #545454;
						margin-top: 5rpx;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
						width: 380rpx;
					}

					.ls-size {
						font-size: 22rpx;
						letter-spacing: 2rpx;
						color: #989898;
						margin: 10rpx 0 20rpx 0;
					}

					.ls-price {
						font-size: 28rpx;
						letter-spacing: 3rpx;
						color: #d81e06;
					}
				}

				.right-num {
					margin-top: 90rpx;
					font-size: 30rpx;
					letter-spacing: 3rpx;
					color: #363636;
				}
			}
		}

		.goods-total {
			margin: 25rpx 0 39rpx 33rpx;
			display: flex;
			align-items: center;

			.total-text {
				font-size: 24rpx;
				letter-spacing: 2rpx;
				color: #787878;
			}

			.total-price {
				font-size: 24rpx;
				letter-spacing: 2rpx;
				color: #d81e06;

				.text- {
					font-size: 30rpx;
					font-weight: bold;
					letter-spacing: 3rpx;
					color: #d81e06;
				}
			}
		}

		.order-btn-s {
			display: flex;
			justify-content: flex-end;
			padding-right: 20rpx;

			.btn-s {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 183rpx;
				height: 65rpx;
				background-color: #c60122;
				border-radius: 33rpx;
				border: solid 1rpx #949494;
				font-size: 30rpx;
				letter-spacing: 3rpx;
				color: #ffffff;
				margin-right: 20rpx;
			}

			.btn-s_ {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 183rpx;
				height: 65rpx;
				background-color: #ffffff;
				border-radius: 33rpx;
				border: solid 1rpx #dcdcdc;
				font-size: 30rpx;
				letter-spacing: 3rpx;
				color: #989898;
			}

			.btn-s__ {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 183rpx;
				height: 65rpx;
				background-color: #ffffff;
				border-radius: 10rpx;
				border: solid 1rpx #dcdcdc;
				font-size: 30rpx;
				letter-spacing: 3rpx;
				color: #989898;
			}
		}

		.item-line-t {
			width: 100%;
			height: 15rpx;
			background-color: #f5f5f5;
			border-radius: 5rpx;
		}
	}
</style>
